package terra.model.effect;

import java.io.IOException;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.particles.ParticleIO;
import org.newdawn.slick.particles.ParticleSystem;

import terra.managers.ResourceManager;
import terra.model.GameObject;
import terra.slick.GameState;

public class ResurectionEffect extends AbstractEffect {

	int objectId;
	ParticleSystem system;
	public ResurectionEffect(int oId){
		objectId = oId;
		time = 2000;
		try {
			system = ParticleIO.loadConfiguredSystem(ResourceManager.getText("RESURECT"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void draw(Graphics g) {
		GameObject obj = GameState.getInstance().objects.get(objectId);
		if (obj != null)
			system.render(obj.getX()+ obj.getW()/2, obj.getY()+ obj.getH()/2);
	}

	@Override
	public void update(int delta) {
		super.update(delta);
		system.update(delta);
	}	
	
	@Override
	public void end() {
		remove = true;
	}

}
